<?php

class error
{

    static $_Instance;

    public static  function getInstance($level, $message, $file, $line)
    {
        if (!isset(self::$_Instance))
        {
            self::$_Instance == new error($level, $message, $file, $line);
        }
        self::set($level, $message, $file, $line);
        return self::$_Instance;
    }

    public static function set($level, $message, $file, $line)
    {
        if ($level > E_WARNING)
        {
            $_Log = core::load('logs');
            $tab = array(
  'FILE' => $file,
  'LINE' => $line,
  'MESSAGE' =>  $message,
  'DATE' => date("H:i:s"),
  'HEURE' => date("j, n, Y"),
            );

            Logs::log('error',      $tab);
            Logs::set('FILE',       $file);
            Logs::set('LINE',       $line);
            Logs::set('MESSAGE',    $message);
            Logs::set('DATE',       date("H:i:s"));
            Logs::set('HEURE',      date("j, n, Y"));
            Logs::record();
 
        }

        $content = file_get_contents(TPL_DIR.'default'.DIR_SEP.'layouts'.DIR_SEP.'error.html');
        $content = str_replace('{message}', $message, $content);
        echo $content;
        die();
        
    }
}